package com.zxw.cloud.gateway.ab;


import org.springframework.http.HttpHeaders;
import org.springframework.core.NamedThreadLocal;
import org.springframework.lang.Nullable;

import java.util.Map;

/**
 *
 * @author zouxw
 */
public class ReactiveRequestContextHolder {

    private static final ThreadLocal<Map<String,Object>> requestHeadersHolder = new NamedThreadLocal("Request attributes");

    public static void setRequestAttributes(Map<String,Object>  headers) {

        requestHeadersHolder.set(headers);
    }

    @Nullable
    public static Map<String,Object> getRequestHeaders() {
        Map<String,Object> headers = requestHeadersHolder.get();
        if (headers == null) {
            headers = requestHeadersHolder.get();
        }

        return headers;
    }

}